package cn.iocoder.yudao.module.resource.dal.mysql.audiomark;


import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.resource.dal.dataobject.audio.LmAudioDO;
import cn.iocoder.yudao.module.resource.dal.dataobject.audiomark.AudioMarkDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 音频和标签及关键字的绑定 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface AudioMarkMapper extends BaseMapperX<AudioMarkDO> {


    List<LmAudioDO> queryAudioByMark(@Param("audioToneId") Integer audioToneId, @Param("tagList") List<String> tagList,
                                     @Param("keyWordList") List<String> keyWordList);

    List<Integer> queryAudioIdListByTag(@Param("tagList") List<String> tagList);

    List<Integer> queryAudioIdListByKeyword(@Param("keywordList") List<String> keywordList);

    default void removeOldMark(Integer audioId) {
        this.delete(AudioMarkDO::getAudioId, audioId);
    }

    default List<AudioMarkDO> getAudioMarkByFileId(Integer audioId) {
        LambdaQueryWrapperX<AudioMarkDO> queryWrapperX = new LambdaQueryWrapperX<>();
        queryWrapperX.eq(AudioMarkDO::getAudioId, audioId);
        return selectList(queryWrapperX);
    }

}